package com.example.springbootdemo.controller;


import com.example.springbootdemo.entity.User;
import com.example.springbootdemo.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@Tag(name= "用户管理", description = "用户管理接口")
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("register")
    @Operation(description = "用户注册",tags = {"用户管理"})
    public User registerUser(@RequestBody User user) {
        return userService.registerUser(user);
    }

    @RequestMapping(value = "searchUserByName", method = RequestMethod.POST)
    @Operation(description = "根据用户名查询用户",tags = {"用户管理"})
    public User searchUserByName(@RequestBody String username) {
        return userService.searchUserByName(username);
    }

    @PostMapping("deleteUserById")
    @Operation(description = "根据用户id删除用户",tags = {"用户管理"})
    public Boolean deleteUserById(@RequestBody Integer id) {

        return userService.deleteUserById(id);
    }


}
